import os
import re
import time
mydir=os.listdir('.')
mydir.remove('update_test.py')


#保存需要修改的文件路径
test_list=[ './'+x for x in mydir if re.search('\.html',x)]
dir_list=[ './'+x for x in mydir if not re.search('\.html',x)]


for x in dir_list:
    if not x in ['./js','./goods']:
        continue
    forlistdir=[ x+'/'+i for i in os.listdir(x) if re.search(r'.html',i) or re.search(r'.js',i)]
    test_list=test_list+forlistdir


new_data='www.meiduo.site:8080' #新数据
past_data='www.meiduo.site:8090' #旧数据

#更该字符
while True:
    for pathtest in test_list:
        with open(pathtest, encoding='utf-8') as o:
            testdata=o.read().replace(past_data,new_data)

        with open(pathtest,'w', encoding='utf-8') as o:
            o.write(testdata)
        print(pathtest+'\t'+'已修改')
    time.sleep(5)








